package com.gmall.product.controller;


import com.gmall.common.result.Result;
import com.gmall.model.product.BaseTrademark;
import com.gmall.model.product.dto.BaseCategoryTrademarkDTO;
import com.gmall.product.service.BaseCategoryTrademarkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin/product/baseCategoryTrademark")
public class BaseCategoryTrademarkController {

    @Autowired
    BaseCategoryTrademarkService baseCategoryTrademarkService;

    @GetMapping("findBaseTrademarkListByCategory3Id/{category3Id}")
    public Result<List<BaseTrademark>> findBaseTrademarkListByCategory3Id(@PathVariable Long category3Id){
        List<BaseTrademark> baseTrademarkList =
                baseCategoryTrademarkService.findBaseTrademarkListByCategory3Id(category3Id);
        return Result.ok(baseTrademarkList);
    }

    @GetMapping("findNotExistBaseTrademarkListByCategory3Id/{category3Id}")
    public Result<List<BaseTrademark>> findNotExistBaseTrademarkListByCategory3Id(@PathVariable Long category3Id){

        List<BaseTrademark> baseTrademarkList =
                baseCategoryTrademarkService.findNotExistBaseTrademarkListByCategory3Id(category3Id);
        return Result.ok(baseTrademarkList);
    }

    /**
     * 192,[4,5]
     * @return
     */
    @PostMapping("/save")
    public Result<String> save(@RequestBody BaseCategoryTrademarkDTO baseCategoryTrademarkDTO){
        baseCategoryTrademarkService.save(baseCategoryTrademarkDTO);
        return Result.ok();
    }

    @DeleteMapping("/remove/{category3Id}/{trademarkId}")
    public Result<String> remove(@PathVariable Long category3Id,@PathVariable Long trademarkId){
        baseCategoryTrademarkService.remove(category3Id,trademarkId);
        return Result.ok();
    }
}
